package com.xcity.pomelo.response;

import com.xcity.game.assist.AssistBuild;
import com.xcity.game.buildv2.BuildV2;

import naga.x.game.time.TimeUpdater;
import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class TakeBuildMoneyV2Response extends Response{
	public int buildId;
	public int lastTakeMoney;
	public int takeMoneyElapseSec;
	public TakeBuildMoneyV2Response(int serial, BuildV2 build, AssistBuild assbuild, int takeMoney, long now) {
		super(serial);
		this.buildId = build.getId();
		this.lastTakeMoney = build.printAndResetLastTakeMoney();
		this.takeMoneyElapseSec = build.calcTakeMoneyElapseSecond();
		if(assbuild != null){
			this.lastTakeMoney = takeMoney;
			this.takeMoneyElapseSec = (int)((now - assbuild.getLastStartMakeMoneyTime())/1000L);
			if(assbuild.getLastStartMakeMoneyTime() > build.getAssistTime() + BuildV2.BUILD_RETURN_MILLISECOND){
				this.takeMoneyElapseSec = -1;
			}
		}
	}

}
